﻿using BW.MesProject.Public.ErrorCode;
using BW.MesProject.WareHouse.Domain;
using BW.MesProject.WareHouse.Infrastructure;
using BW.MesProject.WareHouse.Infrastructure.Dto.Input;
using BW.MesProject.WareHouse.Infrastructure.Dto.OutPut;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace BW.MesProject.WareHouse.Host.Controllers
{
    /// <summary>
    /// 职位
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class JobController : ControllerBase
    {
        // GET: api/<JobController>
        private readonly IJobServices JobServices;

        /// <summary>
        /// 
        /// </summary>
        /// <param name="JobServices"></param>
        public JobController(IJobServices JobServices)
        {
            this.JobServices = JobServices;
        }
        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        [HttpPost]
        public ApiResult<int> AddJob(JobModel model)
        {
            return JobServices.AddJob(model);
        }
        ///// <summary>
        ///// 查询
        ///// </summary>
        ///// <returns></returns>
        //[HttpGet]
        //public ApiResult<List<JobOut>> GetJob([FromQuery] QryInput qryInput)
        //{
        //    return JobServices.GetJob(qryInput);
        //}
        /// <summary>
        /// 查询
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public ApiResult<List<JobOut>> GetJob(string DepId)
        {
            return JobServices.GetJob(DepId);
        }

        /// <summary>
        /// 查询
        /// </summary>
        /// <param name="JobId"></param>
        /// <returns></returns>
        [HttpGet]
        public ApiResult<JobOut> GetJobById(string JobId)
        {
            return JobServices.GetJobById(JobId);
        }
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        [HttpPost]
        public ApiResult<int> UpdatJob(JobModel model)
        {
            return JobServices.UpdateJob(model);
        }

        /// <summary>
        /// 修改启用
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        [HttpPut]
        public ApiResult<int> UpdateEnable(JobModel model)
        {
            return JobServices.UpdateEnable(model);
        }


        /// <summary>
        /// 软删除
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        [HttpDelete]
        public ApiResult<int> UpdateDelete(string Id)
        {
            return JobServices.UpdateDelete(Id);
        }

        /// <summary>
        /// 查询编码
        /// </summary>
        /// <param name="JobId"></param>
        /// <returns></returns>
        [HttpGet]
        public ApiResult<int> GetJobId(string JobId)
        {
            return JobServices.GetJobId(JobId);
        }
    }
}
